package org.xx.armory.web.tags;

import javax.servlet.jsp.JspException;
import org.apache.commons.lang3.StringUtils;

public abstract class BaseHtmlTagHandler extends BaseTagHandler {
    private static final long serialVersionUID = 1L;
    private String lang = "";
    private String title = "";
    private String style = "";
    private String cssClass = "";

    protected BaseHtmlTagHandler() {
    }

    public final String getLang() {
        return this.lang;
    }

    public final void setLang(String value) {
        this.lang = StringUtils.trimToEmpty(value);
    }

    public final String getCssClass() {
        return this.cssClass;
    }

    public final void setCssClass(String value) {
        this.cssClass = StringUtils.trimToEmpty(value);
    }

    public final String getStyle() {
        return this.style;
    }

    public final void setStyle(String value) {
        this.style = StringUtils.trimToEmpty(value);
    }

    public final String getTitle() {
        return this.title;
    }

    public final void setTitle(String value) {
        this.title = StringUtils.trimToEmpty(value);
    }

    public int doStartTag() throws JspException {
        if (!this.getLang().isEmpty()) {
            this.setValue("lang", this.getLang());
        }

        if (!this.getTitle().isEmpty()) {
            this.setValue("title", this.getTitle());
        }

        if (!this.getStyle().isEmpty()) {
            this.setValue("style", this.getStyle());
        }

        if (!this.getCssClass().isEmpty()) {
            this.setValue("class", this.getCssClass());
        }

        this.setAllAttributes();
        this.getRenderer().startTag(this.getTagName(), this.isEmptyContent());
        return 0;
    }

    public int doEndTag() throws JspException {
        this.getRenderer().endTag();
        return super.doEndTag();
    }

    protected abstract String getTagName();

    protected boolean isEmptyContent() {
        return true;
    }
}

